package com.techsoul.module.tms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.techsoul.module.tms.pojo.entity.TFoTransitRoute;
import com.techsoul.module.tms.pojo.param.TFoTransitRouteSearchParam;
import com.techsoul.module.tms.pojo.vo.TFoTransitRouteVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 运输线路Mapper接口
 * 
 * @author liuen
 * @date 2023-06-02
 */
public interface TFoTransitRouteMapper extends BaseMapper<TFoTransitRoute> {

    /**
     * 详情
     * @param id
     * @return
     */
    TFoTransitRouteVo findById(String id);
    TFoTransitRouteVo findByCarrierName(@Param("params") TFoTransitRouteSearchParam params);

    /**
     * 列表
     * @param params
     * @return
     */
    List<TFoTransitRouteVo> findAll(@Param("params") TFoTransitRouteSearchParam params);

    /**
     * 分页
     * @param page
     * @param params
     * @return
     */
    IPage<TFoTransitRouteVo> findAll(Page page, @Param("params") TFoTransitRouteSearchParam params);
    List<TFoTransitRouteVo> findByPickLoc(@Param("departure") String departure, @Param("destination") String destination);
    List<TFoTransitRouteVo> findByPickLocBySite(@Param("departure") String departure, @Param("destination") String destination, @Param("site") String site);
    List<TFoTransitRouteVo> findByPickLocDriver(@Param("departure") String departure, @Param("destination") String destination);
    TFoTransitRouteVo findByPickLocAndDestBySite(@Param("departure") String departure, @Param("destination") String destination, @Param("site") String site);
    List<TFoTransitRouteVo> findByPickLocAndVinfo(@Param("departure") String departure, @Param("destination") String destination, @Param("vehicleModel") String vehicleModel);
    TFoTransitRoute findByPickLocAndDestBySiteEntity(@Param("departure") String departure, @Param("destination") String destination, @Param("site") String site);

    @Select("select max(c.route_code) from t_fo_transit_route c where c.route_code like '${routeCode}%'")
    String getMaxRouteCode(@Param("routeCode") String routeCode);
}
